import requests
import re

url = 'https://www.douban.com/group/topic/331477478/'

response = requests.get(url, headers={
    'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.3'
})

# 从响应头中提取Set-Cookie
set_cookies = response.headers.get('Set-Cookie', '')
cookies = {}

# 使用正则表达式解析Cookie
for match in re.finditer(r'([^=]+)=([^;]+);', set_cookies):
    cookies[match.group(1)] = match.group(2)

print("解析出的Cookie:", cookies)
